package com.heima.search.colltroller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.search.dto.AssociateDto;
import com.heima.model.common.search.vo.AssociateWordsVo;
import com.heima.search.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/api/v1/associate")
public class AssociateColltroller {

    @Autowired
    private HistoryService historyService;

    /**
     * 自动补全
     * @param dto
     * @return
     */
    @PostMapping("/search")
    public ResponseResult<List<AssociateWordsVo>> searchAssociate(@RequestBody AssociateDto dto) throws IOException {
        return historyService.searchAssociate(dto);
    }
}
